#!/bin/bash

dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source "${dir}/../helpers.bash"
# dir might have been overwritten by helpers.bash
dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

function copy_k8s_test_files {
  local K8S1="k8s1"
  local K8S2="k8s2"
  local K8S_FILES_DIR="tests/k8s/tests/${CILIUM_FILES}"
  local VM1=$(get_k8s_vm_name $K8S1)
  local VM2=$(get_k8s_vm_name $K8S2)
  
  echo "VM1: $VM1"
  echo "VM2: $VM2"
 
  # Change to the directory where the K8s Vagrant VMs are accessible.
  cd ${WORKSPACE}/tests/k8s

  copy_files_vm ${VM1} ${K8S_FILES_DIR}
  copy_files_vm ${VM2} ${K8S_FILES_DIR}

  cd ${WORKSPACE}

  echo "----- creating a tarball of files copied from $VM -----"
  # BUILD_ID is generated in helpers.bash. 
  sudo tar -czvf ${CILIUM_FILES}-k8s-${BUILD_ID}.tar.gz ${CILIUM_FILES}-${K8S1}-build-${BUILD_ID} ${CILIUM_FILES}-${K8S2}-build-${BUILD_ID}
  echo "----- done creating a tarball of files copied from $VM -----"
}

copy_k8s_test_files
